package com.sls.web.manager.action.ekhui;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sls.web.manager.action.SuperAction;
import com.sls.web.manager.common.Constants;
import com.sls.web.manager.common.DateUtil;
import com.sls.web.manager.game.client.FundFlowClient;
import com.sls.web.manager.game.pojo.ekhui.FundFlow;
import com.sls.web.manager.game.querybean.FundflowQuery;
import com.sls.web.manager.page.Pagination;
import com.sls.web.manager.pojo.UserInfoVO;

public class FundflowAction extends SuperAction {
	private Logger log = LoggerFactory.getLogger(FundflowAction.class) ;
	private List<FundFlow> fundflowList  ;
	private Pagination<FundFlow> page;
	private FundFlow fundflow ;
	private FundflowQuery fundflowQuery ;
	protected String startTime ;
	protected String endTime ;
	protected int recordCount ;
	public String list(){
		UserInfoVO userInfoVO = getCurrentOperator() ;
		FundFlowClient client = FundFlowClient.getInstance() ;
		if(fundflow == null){
			fundflow = new FundFlow() ;
		}
		if (fundflowQuery == null) {
			fundflowQuery = new FundflowQuery();
			fundflowQuery.setPageSize(Constants.INIT_PAGESIZE);
			fundflowQuery.setCurrentPage(Constants.INIT_CURRENTPAGE);
		}
		recordCount = client.getFundFlowCount(userInfoVO, fundflow, getStartTime(),
				getEndTime()) ;
		
		if(page == null){
			page = new Pagination<FundFlow>(fundflowQuery.getCurrentPage() , recordCount , fundflowQuery.getPageSize()) ;
		}
		fundflowList = client.getFundFlowList(userInfoVO, fundflow, getStartTime(),
				getEndTime(), page.getCurrentPage(), page.getPageSize()) ;
		
		page.setRowCount(recordCount) ;
		page.setList(fundflowList) ;
		return "list" ;
	}
	public List<FundFlow> getFundflowList() {
		return fundflowList;
	}
	public void setFundflowList(List<FundFlow> fundflowList) {
		this.fundflowList = fundflowList;
	}
	public Pagination<FundFlow> getPage() {
		return page;
	}
	public void setPage(Pagination<FundFlow> page) {
		this.page = page;
	}
	public FundFlow getFundflow() {
		return fundflow;
	}
	public void setFundflow(FundFlow fundflow) {
		this.fundflow = fundflow;
	}
	public FundflowQuery getFundflowQuery() {
		return fundflowQuery;
	}
	public void setFundflowQuery(FundflowQuery fundflowQuery) {
		this.fundflowQuery = fundflowQuery;
	}
	public String getStartTime() {
		if(StringUtils.isBlank(startTime)){
			startTime = DateUtil.getTodayBegin() ;
		}
		return startTime;
	}
	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}
	public String getEndTime() {
		if(StringUtils.isBlank(endTime)){
			endTime = DateUtil.getTodayEnd() ;
		}
		return endTime;
	}
	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}
	public int getRecordCount() {
		return recordCount;
	}
	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}
}
